import Condition from './condition';
import Util from '@/lib/util';
export default class Line{
    from:string;
    to:string;
    label:string;
    conditions?:Condition[];

    compare(fromData:any):boolean{
        let result:boolean=true;
        this.conditions.forEach(condition=>{
            const isDigital:boolean=Util.isNumber(condition.value);
            if(isDigital){
                switch(condition.operation){
                    case '=':
                        result= result && fromData[condition.value]==condition.value;
                        break;
                    case '>':
                        result= result && fromData[condition.value]>condition.value;
                        break;
                    case '>=':
                        result= result && fromData[condition.value]>=condition.value;
                        break;
                    case  '<':
                        result= result && fromData[condition.value]<condition.value;
                        break;
                    case '<=':
                        result= result && fromData[condition.value]<=condition.value;
                        break;
                }
            }
            else{
                result =result && condition.value.toLowerCase()===fromData[condition.field];
            }
        });
        return result;
    }
}

